<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<jsp:include page="../inc.jsp"></jsp:include>
<script type="text/javascript">
	$(function() {
		$('#zzgl_njgl_datagrid').datagrid({
			url : '${pageContext.request.contextPath}/school/gradeAction!datagrid.action',
			fit : true,
			fitColumns : true,
			border : false,
			rownumbers : true,
			pagination : true,
			idField : 'id',
			singleSelect:true,
			//checkOnSelect:false,
			columns : [ [ {
				field : 'id',
				title : '编号',
				width : 100,
				align : 'center',
				checkbox : true
			}, {
				field : 'gradeId',
				title : '编号',
				width : 150,
				align : 'center',
				sortable : true
			}, {
				field : 'gradeName',
				title : '年级名称 ',
				width : 150,
				align : 'center',
				sortable : true
			}, {
				field : 'isEnable',
				title : '启用',
				width : 150,
				align : 'center',
				sortable : true
			} ] ],
			toolbar : [ {
				text : '查看所有',
				iconCls : 'icon-reload',
				handler : function() {
					searchAllFun();
				}
			}, '-', {
				text : '编辑',
				iconCls : 'icon-edit',
				handler : function() {
					modify();
				}
			}, '-', {
				text : '添加',
				iconCls : 'icon-add',
				handler : function() {
					append();
				}

			}, '-', {
				text : '删除',
				iconCls : 'icon-remove',
				handler : function() {
					remove();
				}
			} ]
		});
		$('#zzgl_njgl_gradeIdCmb').combobox({
			url : '${pageContext.request.contextPath}/school/gradeAction!getGradeCmb.action',
			valueField : 'gradeId',
			textField : 'gradeId'
		});
		$('#zzgl_njgl_gradeNameCmb').combobox({
			url : '${pageContext.request.contextPath}/school/gradeAction!getGradeCmb.action',
			valueField : 'gradeName',
			textField : 'gradeName'
		});
	});
	function searchAllFun() {
		$('#zzgl_njgl_gradeIdCmb').combobox('setText', '');
		$('#zzgl_njgl_gradeNameCmb').combobox('setText', '');
		$('#zzgl_njgl_isEanbleCmb').combobox('setText', '');
		$('#zzgl_njgl_datagrid').datagrid('load', {});
	}
	function modify() {
		var rows = $('#zzgl_njgl_datagrid').datagrid('getChecked');
		if (rows.length == 1) {
			$('#zzgl_njgl_editForm').form('load',rows[0]);
			$('#zzgl_njgl_editDialog').dialog('open');
		} else {
			$.messager.alert('提示', '请选择你要操作一行!');
		}
	}
	function append() {
		$('#zzgl_njgl_addForm input').val('');
		$('#zzgl_njgl_addDialog').dialog('open');
	}
	function remove() {
		var rows=$('#zzgl_njgl_datagrid').datagrid('getChecked');
		var ids=[];
		//alert(rows[0].id);
		if(rows.length>0){
			$.messager.confirm('确认','是否确认删除选中的记录？',function(r){
			if(r){
				for(var i=0;i<rows.length;i++){
					ids.push(rows[i].id);
				}
				$.ajax({
					url:'${pageContext.request.contextPath}/school/gradeAction!remove.action',
					data:{ids:ids.join(',')},
					dataType:'json',
					success:function(r){
						$('#zzgl_njgl_datagrid').datagrid('load');
						$('#zzgl_njgl_datagrid').datagrid('unselectAll');
						$.messager.show({
							title:'提示',
							msg:r.msg
						});
					}
				});
			}
		});
		}else{
			$.messager.alert('提示','请选择你要操作的行!');
		}
	}
	function searchFun() {
		$('#zzgl_njgl_datagrid').datagrid('load', {
			gradeId : $('#zzgl_njgl_gradeIdCmb').combobox('getText'),
			gradeName : $('#zzgl_njgl_gradeNameCmb').combobox('getText'),
			isEnable : $('#zzgl_njgl_isEanbleCmb').combobox('getText'),
		});
	}
</script>
</head>
<body>
<div class="easyui-layout" data-options="fit:true,border:false">
	<div id="zzgl_njgl_searchPnl" data-options="region:'north',border:false" style="fit:true;overflow:hidden;background-color:#F5F5F5;">
		<table>
			<tr>
				<td style="padding:5px 5px 5px 15px;">编号 ：<input id="zzgl_njgl_gradeIdCmb" name="gradeId" style="width:100px;" /></td>
				<td style="padding:5px 5px 5px 15px;">年级名称：<input id="zzgl_njgl_gradeNameCmb" name="gradeName" style="width:100px;" /></td>
				<td style="padding:5px 5px 5px 15px;">启用： <select id="zzgl_njgl_isEanbleCmb" class="easyui-combobox" name="isEnable" style="width:50px;">
						<option></option>
						<option value="1">是</option>
						<option value="0">否</option>
				</select>
				</td>
				<td style="padding:5px 5px 5px 15px;"><a href="#" class="easyui-linkbutton" data-options="border:false,iconCls:'icon-search',plain:true" onclick="searchFun()">查询</a>
				</td>
			</tr>
		</table>
	</div>
	<div data-options="region:'center',iconCls:'icon-table_multiple',title:'显示详细信息',border:false" style="height:200px;">
		<table id="zzgl_njgl_datagrid"></table>
	</div>
</div>
<div id="zzgl_njgl_addDialog" class="easyui-dialog"  data-options="width:470,height:250,modal:true,closed:true,title:'添加',
			buttons : [ {
				text : '确定',
				iconCls : 'icon-ok',
				handler : function() {
					$('#zzgl_njgl_addForm').form('submit', {
						url : '${pageContext.request.contextPath}/school/gradeAction!add.action',
						success : function(r) {
							var obj = jQuery.parseJSON(r);
							if (obj.success) {
								$('#zzgl_njgl_datagrid').datagrid('load');
								$('#zzgl_njgl_addDialog').dialog('close');
							}
							$.messager.show({
								title : '提示',
								msg : obj.msg
							});
						}
					});
				}
			} ]"> 
	<form id="zzgl_njgl_addForm" method="post">
		<table>
			<tr >
				<td style="padding:10px 5px 5px 40px;">id：</td>
				<td><input type="text" name="id" readonly="readonly"  value="自动生成id" style="background:#f5f5f5;"/>
				</td>
			</tr>
			<tr>
				<td style="padding:10px 5px 5px 40px;">年级编号：</td>
				<td><input type="text" name="gradeId" class="easyui-validatebox" data-options="required:true,validType:'length[0,10]',missingMessage:'请输入年级编号！'" />
				</td>
			</tr>
			<tr>
				<td style="padding:10px 5px 5px 40px;">年级名称：</td>
				<td><input type="text" name="gradeName" class="easyui-validatebox" data-options="required:true,validType:'length[0,10]',missingMessage:'请输入年级名称！'" />
				</td>
			<tr>
			<!--  <tr>
				<td style="padding:10px 5px 5px 40px;">启用：</td>
				<td><input name="isEnable" checked="true" value="是" type="radio">是<input name="isEnable" value="否" type="radio">否
				</td>
			<tr>-->
		</table>
	</form>
</div>
<div id="zzgl_njgl_editDialog" class="easyui-dialog" data-options="width:470,height:250,modal:true,closed:true,title:'编辑',
			buttons : [ {
				text : '确定',
				iconCls : 'icon-ok',
				handler : function() {
					$('#zzgl_njgl_editForm').form('submit', {
						url : '${pageContext.request.contextPath}/school/gradeAction!edit.action',
						success : function(r) {
							var obj = jQuery.parseJSON(r);
							if (obj.success) {
								$('#zzgl_njgl_datagrid').datagrid('load');
								$('#zzgl_njgl_editDialog').dialog('close');
							}
							$.messager.show({
								title : '提示',
								msg : obj.msg
							});
						}
					});
				}
			} ]">
	<form id="zzgl_njgl_editForm"  method="post">
		<table>
			<tr style="display:none">
				<td style="padding:10px 5px 5px 40px;">id：</td>
				<td><input type="text" name="id" readonly="readonly" />
				</td>
			</tr>
			<tr>
				<td style="padding:10px 5px 5px 40px;">年级编号：</td>
				<td><input type="text" name="gradeId" class="easyui-validatebox" data-options="required:true,validType:'length[0,10]',missingMessage:'请输入年级编号！'" />
				</td>
			</tr>
			<tr>
				<td style="padding:10px 5px 5px 40px;">年级名称：</td>
				<td><input type="text" name="gradeName" class="easyui-validatebox" data-options="required:true,validType:'length[0,10]',missingMessage:'请输入年级名称！'" />
				</td>
			<tr>
			<tr>
				<td style="padding:10px 5px 5px 40px;">启用：</td>
				<td><input name="isEnable" checked="true" value="是" type="radio">是<input name="isEnable" value="否" type="radio">否
				</td>
			<tr>
		</table>
	</form>
</div>
</body>
</html>

